#include "CPlayerInfoPanel.h"
#include <iostream>

int koboldsKilled = 0;

TCODConsole* CPlayerInfoPanel::Panel;
rect CPlayerInfoPanel::Area;

void CPlayerInfoPanel::cleanup()
{
    delete Panel;
}

void CPlayerInfoPanel::draw()
{
    Panel->clear();

    std::string nameLine = gPlayer->getName();
    nameLine += " the ";
    nameLine += gPlayer->getRace();
    Panel->print(0, 0, nameLine.c_str());

//    Panel->print(0, 1, (std::string("Size: ")+CEntity::Races[gPlayer->getRace()].Size).c_str());

    std::stringstream healthLine;
    healthLine << "HP: " << gPlayer->getHealth() << "/" << gPlayer->getMaxHealth();
    Panel->print(0, 2, healthLine.str().c_str());

    std::stringstream killsLine;
    killsLine << koboldsKilled << " kobolds killed";
    Panel->print(0, 3, killsLine.str().c_str());

    std::stringstream attrLine;
    attrLine << "Str:" << gPlayer->getAttribute("Strength") << " End:" << gPlayer->getAttribute("Endurance");
    Panel->print(0, 4, attrLine.str().c_str());

    Panel->print(0, 6, gPlayer->look(gPlayer->getPosition()).c_str());

    TCODConsole::blit(Panel, 0, 0, Area.width(), Area.height(), TCODConsole::root, Area.upperLeft().x(), Area.upperLeft().y());
}

void CPlayerInfoPanel::init(rect area)
{
    Area = area;

    Panel = new TCODConsole(Area.width(), Area.height());
}
